home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / Toolbars and Status Bars / SimpleToolBar / SimpleToolBar.cs next >
Encoding:
Text File  |  2001-01-15  |  1.5 KB  |  57 lines

  1. //--------------------------------------------
  2. // SimpleToolBar.cs ⌐ 2001 by Charles Petzold
  3. //--------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class SimpleToolBar: Form
  9. {
  10.      public static void Main()
  11.      {
  12.           Application.Run(new SimpleToolBar());
  13.      }
  14.      public SimpleToolBar()
  15.      {
  16.           Text = "Simple Toolbar";
  17.  
  18.                // Create a simple menu (just for show).
  19.  
  20.           Menu = new MainMenu();
  21.           Menu.MenuItems.Add("File");
  22.           Menu.MenuItems.Add("Edit");
  23.           Menu.MenuItems.Add("View");
  24.           Menu.MenuItems.Add("Help");
  25.  
  26.                // Create ImageList.
  27.  
  28.           Bitmap bm = new Bitmap(GetType(), 
  29.                                  "SimpleToolBar.StandardButtons.bmp");
  30.  
  31.           ImageList imglst = new ImageList();
  32.           imglst.Images.AddStrip(bm);
  33.           imglst.TransparentColor = Color.Cyan;
  34.  
  35.                // Create ToolBar.
  36.  
  37.           ToolBar tbar = new ToolBar();
  38.           tbar.Parent = this;
  39.           tbar.ImageList = imglst;
  40.           tbar.ShowToolTips = true;
  41.  
  42.                // Create ToolBarButtons.
  43.  
  44.           string[] astr = {"New", "Open", "Save", "Print", 
  45.                            "Cut", "Copy", "Paste" };
  46.  
  47.           for (int i = 0; i < 7; i++)
  48.           {
  49.                ToolBarButton tbarbtn = new ToolBarButton();
  50.                tbarbtn.ImageIndex = i;
  51.                tbarbtn.ToolTipText = astr[i];
  52.  
  53.                tbar.Buttons.Add(tbarbtn);
  54.           }
  55.      }
  56. }
  57.